<template>
	<view>
		<image class="banner" src="https://test.hawklu.com/capp/lmbanner.png" mode="widthFix"></image>			 
		<view class="lmList">
			<block v-for="(item,index) in dataList" :key="index">
				<lmItem  :lmItem="item"></lmItem>
			</block>
			<block >
				<emptyBox v-if="dataList.length<1"></emptyBox>
			</block>
		</view>
		
		
	</view>
</template>

<script>
	import {mapState,mapGetters,mapMutation,mapActions} from "vuex";
	import lmItem from "../../components/lmItem/lmItem.vue";
	export default {
		components:{
			lmItem
		},
		data() {
			return {
				dataList:[],
			};
		},
		methods:{
			
			
			getData(){
				this.$store.dispatch("apiGetLmAct").then(res=>{
					
					this.dataList=res.data.data.items;										
				// 以下是实现活动结束时间倒序显示正在进行中的商家联盟活动列表代码
					var len = this.dataList.length;
					     var Dlist = this.dataList;
						 // 当返回数据条数大于等于2时再做判断
					     if (len >= 2) {
					      for (var i = 0; i < len-1; i++) {
					       for (var j = 0; j < len - 1 - i; j++) {
					     // 通过比对活动结束时间,调整数据的前后顺序
					        var arr = new Date (Dlist[j].endTime.replace(/-/g,"\/"));							
					        var arr1 = new Date (Dlist[j + 1].endTime.replace(/-/g,"\/"));
					        if (arr > arr1) {
					         var temp = Dlist[j];
					          Dlist[j] = Dlist[j + 1];
					             Dlist[j + 1] = temp;
					        }
					       }
					      }
					     }
				})
			}
		},
		onLoad(){
			this.getData()
		},
		// 下拉刷新
		onPullDownRefresh() {
			setTimeout(() => {
				this.getData()
				uni.stopPullDownRefresh();
			}, 1500)
		},
	}
</script>

<style lang="less">
	.banner{
		width: 100%;
		height: 240upx;
	}
	.lmList{
		display: flex;
		flex-direction: column;
		padding: 18upx;
	}
	page{
		background-color: #f6f6f6;
	}
	
	
	
	
	
	
	.content1{
	    height: 150upx;
	}
	
	// page{
	//     background-color: pink;
	// }
	/* 搜索框 */
	.search-ico, .search-ico-1{
	    width: 40upx;
	    height: 40upx;
	}
	.search-text{
	    font-size: 14px;
	    background-color: #FFFFFF;
	    height: 60upx;
	    width: 480upx;
	}
	.search-block{
	    display: flex;
	    flex-direction: row;
	    padding-left: 60upx;
	    position: relative;
	    top: -32upx;
	}
	.search-ico-wapper{
	    background-color: #FFFFFF;
	    display: flex;
	    flex-direction:column;
	    justify-content: center;
	    padding: 0upx 0upx 0upx 40upx;
	    border-bottom-left-radius:18px;
	    border-top-left-radius: 18px;
	}
	.search-ico-wapper1{
	    background-color: #FFFFFF;
	    display: flex;
	    flex-direction:column;
	    justify-content: center;
	    padding: 0upx 40upx 0upx 0upx;
	    border-bottom-right-radius:18px;
	    border-top-right-radius: 18px;
	}
	.shadow{
	    width: 638upx;
	    height: 60upx;
	    border-radius:18px;
	    -moz-box-shadow:0 0 10px #e6e6e6;
	    -webkit-box-shadow:0 0 10px #e6e6e6;
	    box-shadow:0 0 10px #e6e6e6;
	    position: relative;
	    top: -90upx;
	    left: 60upx;
	}
	
	
	
	
</style>
